package com.example.a22310.myapplication.Beans;

import android.content.Intent;
import android.databinding.BaseObservable;
import android.databinding.BindingAdapter;
import android.view.View;
import android.widget.ImageView;

import com.squareup.picasso.Picasso;

import java.io.Serializable;

import static com.example.a22310.myapplication.GloableClass.Yuejian.IMG_URL;

public class NewBean extends BaseObservable implements Serializable {

    /**
     * id : 1
     * club_id : 3
     * send_id : 1
     * user_name : 段绪宏
     * user_picture : xd.jpg
     * content : 你好！
     * send_time : 2017-10-01 13：59
     */

    private int id;
    private int club_id;
    private int send_id;
    private String user_name;
    private String user_picture;
    private String content;
    private String send_time;
    private int success;

    public int getSuccess() {
        return success;
    }

    public void setSuccess(int success) {
        this.success = success;
    }

    public NewBean() {
    }

    public NewBean(int id, int club_id, int send_id, String user_name, String user_picture,
                   String content, String send_time) {
        this.id = id;
        this.club_id = club_id;
        this.send_id=send_id;
        this.user_name = user_name;
        this.user_picture = user_picture;
        this.content = content;
        this.send_time=send_time;
    }
    @BindingAdapter("user_picture")
    public static void loadInternetImage(ImageView iv, String user_picture) {
        Picasso.with(iv.getContext()).load(IMG_URL+user_picture).into(iv);
    }

    @Override
    public String toString() {
        return "New{" +
                "id='" + id + '\'' +
                ", club_id='" + club_id + '\'' +
                ", send_id='" + send_id + '\'' +
                "user_name='" + user_name + '\'' +
                ", user_picture='" + user_picture + '\'' +
                ", content='" + content + '\'' +
                "send_time='" + send_time + '\'' +
                '}';
    }

    public void imgOnClick(View view){
        Intent intent=new Intent(view.getContext(),UserInfo.class);
        //往详情传递数据
        NewBean newBean=new NewBean();
        newBean.setSend_id(getSend_id());
        intent.putExtra("userid",newBean);
        view.getContext().startActivity(intent);
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public int getClub_id() {
        return club_id;
    }

    public void setClub_id(int club_id) {
        this.club_id = club_id;
    }

    public int getSend_id() {
        return send_id;
    }

    public void setSend_id(int send_id) {
        this.send_id = send_id;
    }

    public String getUser_name() {
        return user_name;
    }

    public void setUser_name(String user_name) {
        this.user_name = user_name;
    }

    public String getUser_picture() {
        return IMG_URL+user_picture;
    }

    public void setUser_picture(String user_picture) {
        this.user_picture = user_picture;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public String getSend_time() {
        return send_time;
    }

    public void setSend_time(String send_time) {
        this.send_time = send_time;
    }
}

